package com.nineclock.system.controller;


import com.nineclock.common.entity.Result;
import com.nineclock.system.dto.SysRegisterDTO;
import com.nineclock.system.dto.SysUserDTO;
import com.nineclock.system.pojo.SysUser;
import com.nineclock.system.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("user")
@Api(value = "用户管理接口", tags = "系统服务")
public class SysUserController {

    @Autowired
    private SysUserService userService;

    /**
     * 根据用户名/手机号查询用户信息
     * @return
     */
    @GetMapping("query")
    @ApiOperation("根据用户名/手机号查询用户信息")
    public Result<SysUserDTO> queryUser(@RequestParam String username){
        SysUserDTO userDTO = userService.queryUser(username);
        return Result.success(userDTO);
    }

    /**
     * 用户注册: 注册用户
     * 接口路径：POST/sys/user/register
     */
    @PostMapping("register")
    @ApiOperation("用户注册: 注册用户")
    public Result register(SysRegisterDTO registerDTO){
        userService.register(registerDTO);
        return Result.success();
    }



}
